﻿<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:TwoD="clr-namespace:Chem4Word.UI.TwoD" xmlns:Commands="clr-namespace:Chem4Word.UI.Commands" xmlns:Converters="clr-namespace:Chem4Word.UI.Converters" mc:Ignorable="d" x:Class="Chem4Word.UI.TwoD.NewEditorWindow" x:Name="Window" Title="Chemistry Add-in for Word - 2D Editor" Width="800" Height="600" Background="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}" Closing="RibbonWindow_Closing">

	<Window.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="/Chem4Word.UI;component/TwoD/Strings.xaml" />
			</ResourceDictionary.MergedDictionaries>
			<Converters:DrawingModeToBooleanConverter x:Key="DrawingModeToBooleanConverter" />
		</ResourceDictionary>
	</Window.Resources>

	<Window.CommandBindings>
		<CommandBinding Command="{x:Static Commands:ChemCommands.RotateSelection}" Executed="Rotate_Executed" CanExecute="RotateSelection_CanExecute" />
		<CommandBinding Command="{x:Static Commands:ChemCommands.DeleteSelection}" Executed="DeleteSelection_Executed" CanExecute="DeleteSelection_CanExecute" />
		<CommandBinding Command="{x:Static Commands:ChemCommands.FlipHorizontal}" Executed="FlipHorizontal_Executed" CanExecute="FlipHorizontal_CanExecute" />
		<CommandBinding Command="{x:Static Commands:ChemCommands.FlipVertical}" Executed="FlipVertical_Executed" CanExecute="FlipVertical_CanExecute" />
		<CommandBinding Command="{x:Static Commands:ChemCommands.AddElectron}" Executed="AddElectron_Executed" CanExecute="AddRemoveElectron_CanExecute" />
		<CommandBinding Command="{x:Static Commands:ChemCommands.RemoveElectron}" Executed="RemoveElectron_Executed" CanExecute="AddRemoveElectron_CanExecute" />
		<CommandBinding Command="{x:Static Commands:ChemCommands.AddLabel}" Executed="AddLabel_Executed" CanExecute="AddLabel_CanExecute" />
		<CommandBinding Command="{x:Static Commands:ChemCommands.RemoveLabel}" Executed="RemoveLabel_Executed" CanExecute="RemoveLabel_CanExecute" />
		<CommandBinding Command="{x:Static Commands:ChemCommands.FlipSelection}" Executed="FlipSelection_Executed" CanExecute="FlipSelection_CanExecute" />
		<CommandBinding Command="{x:Static Commands:ChemCommands.RemoveIsotopeNumber}" Executed="RemoveIsotope_Executed" CanExecute="RemoveIsotope_CanExecute" />
		<CommandBinding Command="{x:Static Commands:ChemCommands.SetCharge}" Executed="SetCharge_Executed" CanExecute="SetCharge_CanExecute" />
		<CommandBinding Command="{x:Static Commands:ChemCommands.RemoveCharge}" Executed="RemoveCharge_Executed" CanExecute="RemoveCharge_CanExecute" />
		<CommandBinding Command="{x:Static Commands:ChemCommands.AddProton}" Executed="AddProton_Executed" CanExecute="AddProton_CanExecute" />
		<CommandBinding Command="{x:Static Commands:ChemCommands.RemoveProton}" Executed="RemoveProton_Executed" CanExecute="RemoveProton_CanExecute" />
		<CommandBinding Command="{x:Static Commands:ChemCommands.AddHydrogenDot}" Executed="AddHydrogenDot_Executed" CanExecute="AddHydrogenDot_CanExecute" />
		<CommandBinding Command="{x:Static Commands:ChemCommands.RemoveHydrogenDot}" Executed="RemoveHydrogenDot_Executed" CanExecute="RemoveHydrogenDot_CanExecute" />
		<CommandBinding Command="{x:Static ApplicationCommands.SelectAll}" Executed="SelectAll_Executed" />
		<CommandBinding Command="{x:Static ApplicationCommands.Undo}" Executed="Undo_Executed" CanExecute="Undo_CanExecute" />
		<CommandBinding Command="{x:Static ApplicationCommands.Redo}" Executed="Redo_Executed" CanExecute="Redo_CanExecute" />
		<CommandBinding Command="{x:Static ApplicationCommands.Save}" Executed="Save_Executed" CanExecute="Save_CanExecute" />
	</Window.CommandBindings>

	<Grid x:Name="LayoutRoot">
		<Grid.RowDefinitions>
			<RowDefinition Height="*" />
			<RowDefinition Height="auto" />
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="250" />
			<ColumnDefinition Width="0.646*" />
		</Grid.ColumnDefinitions>
		<DockPanel>
			<Border BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" BorderThickness="1" Height="77" Margin="8,8,8,0" VerticalAlignment="Top" Padding="8" DockPanel.Dock="Top" Background="White" CornerRadius="8">
				<DockPanel>
					<TextBlock TextWrapping="Wrap" Width="216" DockPanel.Dock="Top" Margin="8,8,8,0" FontSize="16" x:Name="mainTextDepiciton" Language="en-gb">Main Representaion</TextBlock>
					<TextBlock TextWrapping="Wrap" DockPanel.Dock="Top" Margin="8,8,8,0" FontSize="16" x:Name="formulaTextDepiction" Language="en-gb">Concise Formula</TextBlock>
				</DockPanel>
			</Border>
			<Border BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" BorderThickness="1" DockPanel.Dock="Top" Margin="8,4,8,0" Padding="8" Background="White" CornerRadius="8">
				<Grid>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto" />
						<ColumnDefinition Width="*" />
					</Grid.ColumnDefinitions>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto" />
						<RowDefinition Height="auto" />
						<RowDefinition Height="auto" />
						<RowDefinition Height="auto" />
						<RowDefinition Height="auto" />
						<RowDefinition Height="auto" />
						<RowDefinition Height="auto" />
						<RowDefinition Height="auto" />
						<RowDefinition Height="auto" />
						<RowDefinition Height="auto" />
						<RowDefinition Height="157*" />
					</Grid.RowDefinitions>
					<TextBlock Grid.Column="0" HorizontalAlignment="Right" TextWrapping="Wrap" d:LayoutOverrides="Height" Foreground="{DynamicResource {x:Static SystemColors.HotTrackBrushKey}}" Margin="8,8,8,4" VerticalAlignment="Center">
						<Run Language="en-gb" Text="Zoom" />
					</TextBlock>
					<DockPanel Grid.Column="1" Margin="8,8,8,4" LastChildFill="False">
						<Button Margin="1" Command="{x:Static NavigationCommands.IncreaseZoom}">
							<Image Source="/Chem4Word.UI;component/Resources/Images/ZoomIn32.png" Width="16" Height="16" />
						</Button>
						<Button Margin="1" Command="{x:Static NavigationCommands.DecreaseZoom}">
							<Image Source="/Chem4Word.UI;component/Resources/Images/ZoomOut32.png" Width="16" Height="16" />
						</Button>
					</DockPanel>
					<Border Grid.Row="1" BorderThickness="0,1,0,0" Grid.ColumnSpan="2" BorderBrush="{DynamicResource {x:Static SystemColors.ActiveCaptionBrushKey}}" />

					<TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right" TextWrapping="Wrap" d:LayoutOverrides="Height" Foreground="{DynamicResource {x:Static SystemColors.HotTrackBrushKey}}" Margin="8,8,8,4" VerticalAlignment="Center">
						<Run Language="en-gb" Text="General" />
					</TextBlock>
					<DockPanel Grid.Row="2" Grid.Column="1" Margin="8,8,8,4" LastChildFill="False">
						<DockPanel DockPanel.Dock="Top" LastChildFill="False">
							<Button Margin="1" Command="{x:Static ApplicationCommands.Save}">
								<Image Source="/Chem4Word.UI;component/Resources/Images/Save16.png" Width="16" Height="16" />
							</Button>
							<Button Margin="1" Command="{x:Static Commands:ChemCommands.DeleteSelection}" ToolTip="{DynamicResource DeleteSelectionTooltip}">
								<Image Source="/Chem4Word.UI;component/Resources/Images/Delete.png" Width="16" Height="16" />
							</Button>
							<Button Margin="1" Command="{x:Static ApplicationCommands.SelectAll}">
								<Image Source="/Chem4Word.UI;component/Resources/Images/Select_All.png" Width="16" Height="16" ToolTip="Select All" />
							</Button>
							<Button Margin="1" Command="{x:Static ApplicationCommands.Undo}">
								<Image Source="/Chem4Word.UI;component/Resources/Images/Undo.png" Width="16" Height="16" ToolTip="Undo" />
							</Button>
							<Button Margin="1" Command="{x:Static ApplicationCommands.Redo}">
								<Image Source="/Chem4Word.UI;component/Resources/Images/Redo.png" Width="16" Height="16" ToolTip="Redo" />
							</Button>
						</DockPanel>
						<GroupBox Header="Selection Mode" DockPanel.Dock="Top">
							<DockPanel>
								<TwoD:RadioButtonExtended Margin="4" DockPanel.Dock="Left" Content="Atom" IsCheckedReal="{Binding ElementName=_editor, Mode=TwoWay, Path=Canvas.DrawingMode, Converter={StaticResource DrawingModeToBooleanConverter}, ConverterParameter=Atom}" />
								<TwoD:RadioButtonExtended Margin="4" DockPanel.Dock="Left" Content="Bond" IsCheckedReal="{Binding ElementName=_editor, Mode=TwoWay, Path=Canvas.DrawingMode, Converter={StaticResource DrawingModeToBooleanConverter}, ConverterParameter=Bond}" />
							</DockPanel>
						</GroupBox>
					</DockPanel>
					<Border Grid.Row="3" BorderThickness="0,1,0,0" Grid.ColumnSpan="2" BorderBrush="{DynamicResource {x:Static SystemColors.ActiveCaptionBrushKey}}" />

					<TextBlock Grid.Row="4" Grid.Column="0" HorizontalAlignment="Right" TextWrapping="Wrap" d:LayoutOverrides="Height" Foreground="{DynamicResource {x:Static SystemColors.HotTrackBrushKey}}" Margin="8,8,8,4" VerticalAlignment="Center">
						<Run Language="en-gb" Text="Atom" />
					</TextBlock>
					<ComboBox Grid.Row="4" Grid.Column="1" Margin="8,8,0,4" x:Name="AtomTypeComboBox" SelectionChanged="AtomTypeComboBox_SelectionChanged" />
					<DockPanel Grid.Row="5" Grid.Column="1" Margin="8,8,8,4" LastChildFill="False">
						<Button Margin="1" Command="{x:Static Commands:ChemCommands.AddElectron}" ToolTip="{DynamicResource AddElectronTooltip}">
							<Image Source="/Chem4Word.UI;component/Resources/Images/AddElectron.png" Width="16" Height="16" />
						</Button>
						<Button Margin="1" Command="{x:Static Commands:ChemCommands.RemoveElectron}" ToolTip="{DynamicResource RemoveElectronTooltip}">
							<Image Source="/Chem4Word.UI;component/Resources/Images/RemoveElectron.png" Width="16" Height="16" />
						</Button>
						<Button Margin="1" Command="{x:Static Commands:ChemCommands.AddProton}" ToolTip="{DynamicResource AddProtonTooltip}">
							<Image Source="/Chem4Word.UI;component/Resources/Images/AddProton.png" Width="16" Height="16" />
						</Button>
						<Button Margin="1" Command="{x:Static Commands:ChemCommands.RemoveProton}" ToolTip="{DynamicResource RemoveProtonTooltip}">
							<Image Source="/Chem4Word.UI;component/Resources/Images/RemoveProton.png" Width="16" Height="16" />
						</Button>
						<Button Margin="1" Command="{x:Static Commands:ChemCommands.AddHydrogenDot}" ToolTip="{DynamicResource AddHydrogenDotTooltip}">
							<Image Source="/Chem4Word.UI;component/Resources/Images/AddHydrogenDot.png" Width="16" Height="16" />
						</Button>
						<Button Margin="1" Command="{x:Static Commands:ChemCommands.RemoveHydrogenDot}" ToolTip="{DynamicResource RemoveHydrogenDotTooltip}">
							<Image Source="/Chem4Word.UI;component/Resources/Images/RemoveHydrogenDot.png" Width="16" Height="16" />
						</Button>
					</DockPanel>
					<DockPanel Grid.Row="6" Grid.Column="1" Margin="8,8,8,4" LastChildFill="False">
						<Button Margin="1" Command="{x:Static Commands:ChemCommands.RotateSelection}" ToolTip="{DynamicResource RotateTooltip}">
							<Image Source="/Chem4Word.UI;component/Resources/Images/Rotate.png" Width="16" Height="16" />
						</Button>
						<Button Margin="1" Command="{x:Static Commands:ChemCommands.FlipSelection}" ToolTip="{DynamicResource FlipSelectionTooltip}">
							<Image Source="/Chem4Word.UI;component/Resources/Images/FlipAboutBond.png" Width="16" Height="16" />
						</Button>
						<Button Margin="1" Command="{x:Static Commands:ChemCommands.FlipHorizontal}" ToolTip="{DynamicResource FlipHorizontalTooltip}">
							<Image Source="/Chem4Word.UI;component/Resources/Images/FlipHorizontal.png" Width="16" Height="16" />
						</Button>
						<Button Margin="1" Command="{x:Static Commands:ChemCommands.FlipVertical}" ToolTip="{DynamicResource FlipVerticalTooltip}">
							<Image Source="/Chem4Word.UI;component/Resources/Images/FlipVertical.png" Width="16" Height="16" />
						</Button>
					</DockPanel>
					<Border Grid.Row="7" BorderThickness="0,1,0,0" Grid.ColumnSpan="2" BorderBrush="{DynamicResource {x:Static SystemColors.ActiveCaptionBrushKey}}" />

					<TextBlock Grid.Row="8" Grid.Column="0" HorizontalAlignment="Right" TextWrapping="Wrap" d:LayoutOverrides="Height" Foreground="{DynamicResource {x:Static SystemColors.HotTrackBrushKey}}" Margin="8,8,8,4" VerticalAlignment="Center">
						<Run Language="en-gb" Text="Isotope" />
					</TextBlock>
					<ComboBox Grid.Row="8" Grid.Column="1" Margin="8,8,0,4" x:Name="IsotopeOptionsCombo" SelectionChanged="IsotopeOptionsCombo_SelectionChanged" />
					<DockPanel Grid.Row="9" Grid.Column="1" Margin="8,8,8,4" LastChildFill="False">
						<Button Margin="1" Command="{x:Static Commands:ChemCommands.RemoveIsotopeNumber}" ToolTip="{DynamicResource RemoveIsotopeTooltip}">
							<Image Source="/Chem4Word.UI;component/Resources/Images/RemoveIsotope.png" Width="16" Height="16" />
						</Button>
						<Button Margin="1" Command="{x:Static Commands:ChemCommands.SetCharge}" ToolTip="{DynamicResource SetChargeTooltip}">
							<Image Source="/Chem4Word.UI;component/Resources/Images/SetCharge.png" Width="16" Height="16" />
						</Button>
						<Button Margin="1" Command="{x:Static Commands:ChemCommands.RemoveCharge}" ToolTip="{DynamicResource UnsetChargeTooltip}">
							<Image Source="/Chem4Word.UI;component/Resources/Images/UnsetCharge.png" Width="16" Height="16" />
						</Button>
						<Button Margin="1" Command="{x:Static Commands:ChemCommands.AddLabel}" ToolTip="{DynamicResource AddLabelTooltip}">
							<Image Source="/Chem4Word.UI;component/Resources/Images/AddLabel.png" Width="16" Height="16" />
						</Button>
						<Button Margin="1" Command="{x:Static Commands:ChemCommands.RemoveLabel}" ToolTip="{DynamicResource RemoveLabelTooltip}">
							<Image Source="/Chem4Word.UI;component/Resources/Images/RemoveLabel.png" Width="16" Height="16" />
						</Button>
					</DockPanel>
				</Grid>
			</Border>
		</DockPanel>

		<DockPanel Grid.Column="1" HorizontalAlignment="Right" Margin="0" Grid.Row="1">
			<Button x:Name="CancelButton" Content="Cancel" VerticalAlignment="Top" Width="75" Margin="4,8,8,8" DockPanel.Dock="Right" IsCancel="True" Click="CancelButton_Click" />
			<Button x:Name="OKButton" Content="OK" VerticalAlignment="Top" Width="75" DockPanel.Dock="Right" Margin="8,8,4,8" IsDefault="True" Click="OKButton_Click" />
		</DockPanel>
		<Border BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" BorderThickness="1" Grid.Column="1" Margin="0,8,8,0" Background="White" CornerRadius="8" ClipToBounds="True">
			<TwoD:CanvasContainer x:Name="_editor" Margin="0,0,-10,-10" />
		</Border>
		<TwoD:PeriodicTableElementChooser x:Name="periodicTable" IsHitTestVisible="False" ElementSelected="PeriodicTableElementSelected" Opacity="0" Height="280" Width="561" Background="WhiteSmoke" />
	</Grid>
</Window>